<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('处理电话工单初稿')"/>
    <link th:href="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.css}" rel="stylesheet">
    <link th:href="@{/ajax/libs/bootstrap-tagsinput/tagsinput.css}" rel="stylesheet">
    <link th:href="@{/ajax/libs/jQuery-ui/jquery-ui.css}" rel="stylesheet">
    <link th:href="@{/css/iconfont/iconfont.css}" rel="stylesheet">
    <link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/qxEasyUI/themes/default/easyui.css}">


</head>
<style>
    .fixed-table-pagination > .pull-left {
        display: none;
    }

    .bootstrap-tagsinput > input {
        display: none;
    }

    .tworkformprocess-gjz {
        display: inline-block;
        background-color: #FAFAFA;
        padding: 3px;
        border-radius: 3px;
        margin: 3px;
    }

    label {
        font-weight: bold;
    }

    @font-face {
        font-family: 'huawen';
        src: url("/fonts/huawen.woff2");
    }
</style>

<body style="background-color: #F4F6FA; font-size: 13px;font-family:'huawen' ;font-weight: bold">
<div class="main-content" style="margin: 0;padding: 0;letter-spacing:2px;">

    <form id="form-user-add" th:object="${workFormBase}" class="form-horizontal" style="background-color: #F4F6FA">
        <input type="hidden" name="fromTelA" th:field="*{fromTelA}">
        <input type="hidden" name="fromName" th:field="*{fromName}">
        <input type="hidden" id="pkId" name="pkId" th:field="*{pkId}">
        <input type="hidden" id="getDealPk" name="getDealPk" th:field="*{getDealPk}">
        <input type="hidden" name="crtStepId" id="txtCrtStepId">
        <input type="hidden" name="crtStepName" id="txtCrtStepName">

        <div style="display: flex">

            <!--     左       -->
            <div class="col-sm-8 entering-page" style="max-height: 610px;overflow: auto">
                <!--内上-->
                <div class="col-sm-12" style="margin-top: 10px">
                    <!--来电类容-->
                    <div id="fmContent"
                         style="padding: 5px;background-color: #FAFAFA;border-radius: 12px; height: 80px">
                        [[*{fmContent}]]
                    </div>
                </div>
                <!--内左-->
                <div class="col-sm-6">
                    <!--   来电基本信息     -->
                    <div class="col-sm-12 tltieBoder">
                        <div class="blueBorder"></div>
                        <h4 style="margin:0 0 0 10px">来电基本信息</h4>
                    </div>
                    <!--事发地址-->
                    <div class="form-group col-sm-12">

                        <label class="col-sm-3 control-label  entering-pd">事发地址：</label>
                        <div class="col-sm-9">
                            <span class="tworkformprocess-span">[[*{fmAddress}]]</span>
                            <input name="fmAddress" th:field="*{fmAddress}" type="hidden"/>
                        </div>


                    </div>

                    <div class="form-group col-sm-12">
                        <label class="col-sm-3  control-label entering-pd">流水号&nbsp;&nbsp;：</label>
                        <div class="col-sm-9">
                            <span class="tworkformprocess-span">[[*{wsCode}]]</span>
                            <input name="wsCode" th:field="*{wsCode}" type="hidden"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label entering-pd">提取码&nbsp;&nbsp;：</label>
                        <div class="col-sm-9">
                            <span class="tworkformprocess-span">[[*{wsKey}]]</span>
                            <input name="wsKey" th:field="*{wsKey}" type="hidden"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label entering-pd">被诉主体：</label>
                        <div class="col-sm-9" id="tworkformprocess-zt">
                            <input name="accSubject" th:field="*{accSubject}" type="hidden"/>
                            <div class="tworkformprocess-gjz">[[*{accSubject}]]</div>
                        </div>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label entering-pd">坐席备注：</label>
                        <div class="col-sm-9">
                            <span class="tworkformprocess-span">[[*{xsysDesc}]]</span>
                            <input name="xsysDesc" th:field="*{xsysDesc}" type="hidden">
                        </div>
                    </div>
                    <!-- 单选-->
                    <div class="form-group col-sm-12">

                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">建议公开：</label>
                                <div class="col-sm-3">
                                    <input name="openX" th:checked="*{openX == 1}" th:value="*{openX}" type="checkbox"
                                           data-size="small">

                               </div>
                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">是否督办：</label>
                                <div class="col-sm-3">
                                    <input name="spareInt" th:checked="*{spareInt == 1}" th:value="*{spareInt}" type="checkbox"
                                           data-size="small">
                                </div>
                    </div>
                    <div class="form-group col-sm-12">
                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">重点项目：</label>
                                <div class="col-sm-3">
                                    <input name="project" type="checkbox" data-size="small">
                                </div>
                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">摘报：</label>
                                <div class="col-sm-3">
                                    <input name="reportFlag" th:checked="*{reportFlag == 1}" th:value="*{reportFlag}"
                                           type="checkbox" data-size="small">
                                </div>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">是否紧急：</label>
                        <div class="col-sm-3">
                            <input name="mark" th:checked="*{mark == '1'}" th:value="*{mark}"
                                   type="checkbox" data-size="small">
                        </div>
                    </div>
                </div>
                <!--内右-->
                <div class="col-sm-6" style="border-left: 1px solid #ebebeb">

                    <!--   工单基本信息     -->
                    <div class="col-sm-12 " style="display: flex;justify-content: space-between">
                        <div class="tltieBoder">
                            <div class="blueBorder"></div>
                            <h4 style="margin:0 0 0 10px">工单基本信息</h4>
                        </div>
                        <!--呈批-->
                        <div class="col-sm-6 control-label">
                            <button type="button" class="btn btn-sm btn-primary"
                                    style="margin-top: 9px;color: #206ef7;background-color: white"
                                    onclick="">呈批
                            </button>
                        </div>
                    </div>

                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label  entering-pd">来电类型：</label>
                        <div class="col-sm-9">
                            <select name="dfmClaNo" id="dfmClaNo" required
                                    th:with="telTypes=${@commonServiceImpl.findTelType()}"
                                    onchange="dropChgSendTextOnly(this,'dfmClaName');"
                                    class="form-control formSelect">
                                <option value="">--请选择--</option>
                                <th:block th:each="item : ${telTypes}">
                                    <option th:text="${item['CSText']}" th:value="${item['CSValue']}"
                                            th:selected="${item['CSValue'] eq workFormBase.dfmClaNo}"></option>
                                </th:block>
                            </select>
                            <input type="hidden" name="dfmClaName" id="dfmClaName" th:value="*{dfmClaName}"/>
                        </div>
                    </div>
                    <!--内容类别-->
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label entering-pd">内容类别：</label>
                        <div class="col-sm-9">
                            <input id="qxCT" th:value="*{dcntAname}" style="width:242px;height:31px;">
                            <input id="txtDcntAcode" name="dcntAcode" type="hidden" th:value="*{dcntAcode}"/>
                            <input id="txtDCntAName" name="dcntAname" type="hidden" th:value="*{dcntAname}"/>
                        </div>
                    </div>
                    <!--工单主题-->
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label entering-pd">工单主题：</label>
                        <div class="col-sm-9">
                            <input id="wsTopic" name="wsTopic" th:field="*{wsTopic}" placeholder="请输入"
                                   class="form-control workTheme" type="text"
                                   required="">
                        </div>
                    </div>
                    <!--拟办期限-->
                    <div class="form-group col-sm-12">
                        <label class="col-sm-3 control-label  entering-pd">拟办期限：</label>
                        <div class="col-sm-9">
                            <input name="deadline" th:field="*{wfLimit}" placeholder="请输入" class="form-control deadline"
                                   type="text"
                                   required="">
                        </div>
                        <div class="input-group-append " style="position: absolute;top: 10px;right: 40px;">
                            <span class="glyphicon glyphicon-calendar "></span>
                        </div>
                    </div>

                    <!-- 工单备注-->
                    <div class="form-group col-sm-12">
                        <label class="col-xs-3 control-label entering-pd">工单备注：</label>
                        <div class="col-xs-9">
                                    <textarea name="wfRemark" th:field="*{wfRemark}" maxlength="3500"
                                              class="form-control workRemark"
                                              rows="3" style="height: 65px"></textarea>
                            <span class="tworkformprocess-span">还可以输入<i class="workRemarkI">3500</i>个文字</span>
                        </div>
                    </div>


                </div>
                <!--内下-->
                <div class="col-sm-12" style="margin-top: -16px">
                    <div class="col-sm-12">
                        <div class="btn-group-sm" id="toolbar" role="group">
                            <label class="control-label"> <a class="btn btn-success btn-sm" onclick="proposed()">
                                <i class="fa fa-plus"></i> 新增
                            </a></label>
                        </div>
                        <table id="bootstrap-table"></table>
                    </div>
                    <!--按钮-->
                    <div class="col-sm-12 entering-bt" style="justify-content: center;">
                        <button type="button" class="btn btn-sm btn-info" onclick="dispatch(11)">通过并派单
                        </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="button" class="btn btn-sm btn-success"  onclick="workFormOver()" title="不派单,强制办结工单">直接答复
                        </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="button" class="btn btn-sm btn-warning" onclick="closeItem()">关闭
                        </button>&nbsp;
                    </div>
                </div>

            </div>
            <!--     右       -->
            <div class="col-sm-4 " style="margin: 0;margin-top:5px;padding: 0">
                <div class="col-sm-12 entering-page" style="margin-top: 0">
                    <!--   来电基本信息     -->
                    <div class="col-sm-12 tltieBoder">
                        <div class="blueBorder"></div>
                        <h4 style="margin:0 0 0 10px">来电基本信息</h4>
                    </div>

                    <div class="form-group col-sm-12" style="margin-bottom: 0px">
                        <label class="col-sm-3 control-label entering-pd">工单编号：</label>
                        <div class="col-sm-9">
                            <span class="tworkformprocess-span">[[*{workFormNo}]]</span>
                            <input name="workFormNo" th:field="*{workFormNo}" type="hidden"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-12" style="margin-bottom: 0px">
                        <label class="col-sm-3 control-label entering-pd">工单性质：</label>
                        <div class="col-sm-9">
                            <input name="setProName" th:field="*{setProName}" type="hidden"/>
                            <input name="setProId" id="htbProID" th:field="*{setProId}" type="hidden"/>
                            <span class="tworkformprocess-span">[[*{setProName}]]</span>
                        </div>
                    </div>
                    <!-- 标签-->
                    <div class="form-group col-sm-12" style="margin-bottom: 0px">
                        <label class="col-sm-3  control-label entering-pd">关键词：</label>
                        <div class="col-sm-9" id="tworkformprocess-bq">
                            <input name="keyWord" th:field="*{keyWord}" type="hidden">
                            <div class="tworkformprocess-gjz" th:each="key : *{#strings.arraySplit(keyWord,',')}"
                                 th:text="${key}"></div>
                        </div>
                    </div>
                    <!--单选-->
                    <div class="form-group col-sm-12" style="line-height: 8px;margin-top: 8px;">
                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">屏蔽号码：</label>
                                <div class="col-sm-3">
                                    <span th:text="${telGetDeal != null ? telGetDeal.hideTel == 5 ? '是' : '否' : '否'}"></span>
                                </div>
                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">同意公开：</label>
                                <div class="col-sm-3">
                                    <span th:text="${telGetDeal != null ? telGetDeal.openX == 1 ? '是' : '否' : '否'}"></span>
                                </div>
                    </div>
                    <div class="form-group col-sm-12" style="margin-bottom: 0px">
                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">重复来电：</label>
                                <div class="col-sm-3">
                                    <span th:text="${telGetDeal != null ? telGetDeal.repeatFlag == 1 ? '是' : '否' : '否'}">否</span>
                                </div>

                                <label class="col-sm-3 control-label entering-pd" style="padding-top: 1px">紧急联系：</label>
                                <div class="col-sm-3">
                                    <span th:text="${telGetDeal != null ? telGetDeal.mark == 1 ? '是' : '否' : '否'}">否</span>
                                </div>
                    </div>
                </div>
                <!--类案推荐-->
                <div class="col-sm-12 entering-page" style="height: 406px;overflow: auto">
                    <div class="col-sm-12 tltieBoder">
                        <div class="blueBorder"></div>
                        <h4 style="margin:0 0 0 10px">类案推荐</h4>
                    </div>
                    <div class="main-content" style="margin: 0;padding: 0">
                        <div class="col-sm-12">
                            <div class="work-order box" style="border-top:0;margin-top: 10px">
                                <div class="content">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>

<script th:src="@{/ajax/libs/layui/laydate.js}"></script>
<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/bootstrap-tagsinput/tagsinput.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-switch/bootstrap-switch.min.js}"></script>
<script th:src="@{/ajax/libs/jQuery-ui/jquery-ui.js}"></script>
<script th:src="@{/ajax/libs/qxEasyUI/jquery.easyui.min.js}"></script>
<script th:src="@{/js/Gxqtelsendorder.js}"></script>
<script>
    $('[name="openX"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
            if (state === true) {
                $(this).val(1);
            } else {
                $(this).val(0);
            }
        }
    });
    $('[name="reportFlag"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
            if (state === true) {
                $(this).val(1);
            } else {
                $(this).val(0);
            }
        }
    });
    $('[name="project"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }
    });
    $('[name="spareInt"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }
    });
    $('[name="hideTel"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }
    });
    $('[name="openFrom"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }
    });
    $('[name="repeatFlag"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }
    });
    $('[name="mark"]').bootstrapSwitch({
        onText: "是",
        offText: "否",
        onColor: "success",
        offColor: "info",
        size: "mini",
        onSwitchChange: function (event, state) {
        }
    });
    // let title = $("#txtDCntAName").val() == null ? $('#qxCT').combo('getText') : $("#txtDCntAName").val();
    // let data = {
    //     "title": title,
    //     "topn": 5,
    //     "master_department" : "",
    //     "slave_department" : "",
    //     "resolved" : "",
    //     "satisfied" : "",
    //     "key_points" : "",
    //     "time" : ""
    // }
    // $.ajax({
    //     url: "/api/bd/caseRecommend",
    //     data: JSON.stringify(data),
    //     type: "POST",
    //     dataType: "json",
    //     contentType: "contentType: 'application/json;charset=UTF-8',",
    //     beforeSend: function () {
    //         $('#loading').modal('show');
    //     },
    //     complete: function () {
    //         $('#loading').modal('hide');
    //     },
    //     success: function (res) {
    //         // data = jQuery.parseJSON(data);  //dataType指明了返回数据为json类型，故不需要再反序列化
    //         var contentObj = document.getElementsByClassName("content")[0];
    //         let data = res.data;
    //         if(data.content.length == 0){
    //             contentObj.innerHTML = '没有数据';
    //             $('#expandBtn').parent().hide();
    //         }else {
    //             var isHtml = "";
    //             var arr = data.content;
    //             for (var i = 0; i < arr.length; i++) {
    //                 console.log(arr[i])
    //                 let cid = arr[i].cid == null ? '暂无' : arr[i].cid;
    //                 isHtml += '<div class="col-sm-12 work-box">';
    //                 isHtml += '<div class="work-box-top">';
    //                 isHtml += '<div class="col-sm-12 work-box-top-box">';
    //                 isHtml += '<div class="col-sm-10"><a class="work-box-a"><span>承办部门：' + arr[i].masterDepartment + '</span></a></div>';
    //                 isHtml += '<div class="col-sm-10"><a class="work-box-a"><span>关键词：' + arr[i].keyPoints + '</span></a></div>';
    //                 isHtml += '</div>';
    //                 isHtml += '<div class="col-sm-12 work-box-top-class">'
    //                 isHtml += '<div class="col-sm-6"><a style="color: inherit">相似度：'+Number(arr[i].score * 100).toFixed(1) + "%"+'</a></div>'
    //                 isHtml += '<div class="col-sm-6" ondblclick="caseDetail('+cid+')"><a style="color: inherit">案件编号：'+ cid +'</a></div>'
    //                 isHtml += '</div>'
    //                 isHtml += '<div class="col-sm-12 work-box-class"><a style="color: inherit">案件描述：'+ arr[i].title + '</a></div>';
    //                 isHtml += '<div class="col-sm-12 work-box-buttom">';
    //                 isHtml += '<div class="col-sm-6">最近办结（解决）时间：' + arr[i].time + '</div>';
    //                 isHtml += '<div class="col-sm-4"><div class="col-sm-12 entering-pd">处理情况：'+arr[i].resolved+'</div></div>';
    //                 isHtml += '</div>';
    //                 isHtml += '</div>';
    //                 isHtml += '</div>';
    //             };
    //         }
    //         contentObj.innerHTML = isHtml;
    //     }
    // });

    //类案详情
    function caseDetail(id) {
        var url = ctx + "gaoxin/system/test/caseDetail/"+id;
        var width = '80%';
        var height = 600;
        var title = "类案详情";
        $.modal.openDialog(title, url,width,height);
    }

    var prefix = ctx + "gaoxin/system/mTelRcd";
    var send = ctx + "gaoxin/system/sendBack";
    var work = ctx + "gaoxin/system/workForm";

    function dispatch(opVal) {
        let bootstrapTable = $("#bootstrap-table").bootstrapTable('getData', false);
        console.log(bootstrapTable[0].pkId)
        if (bootstrapTable.length == 0) {
            $.modal.alertWarning("请选择拟办部门");
            return;
        }
        var tmp = $("#htbProID").val();
        switch (opVal.toString()) {
            case "11":
                if ("11" != tmp.toString()) {
                    $("#txtCrtStepId").val("200");
                    $("#txtCrtStepName").val("效能办领导审核");
                } else {//普通工单
                    $("#txtCrtStepId").val("400");
                    $("#txtCrtStepName").val("市级部门处理");
                }
                if ($.validate.form()) {
                    let data = $('#form-user-add').serializeArray();
                    data.push({name:"sendId",value:bootstrapTable[0].pkId});
                    data.push({name:"twsf",value:JSON.stringify(bootstrapTable)});
                    $.operate.saveTab(work + "/dispatch", data);
                }
        }
    }

    function workFormOver() {
        let bootstrapTable = $("#bootstrap-table").bootstrapTable('getData', false);
        if (bootstrapTable.length > 0) {
            $.modal.alertWarning("错误提示：请删除承办部门");
            return;
        }
        let val = $('#pkId').val();
        var url = ctx+'gaoxin/system/mTelWF/rManage/tWFormOver/'+val;
        $.modal.openTab('直接答复工单',url);
    }
    $('#qxCT').combotree({
        url: '/system/common/findContentCate',
        required: false,
        onSelect: function (record) {
            $("#txtDcntAcode").val(record.id);
            $("#txtDCntAName").val(record.text);
            var dfmClaName = $("#dfmClaNo option:selected").text();
            var fromName = $("#fromName").val();
            $("#wsTopic").val(fromName + '[' + dfmClaName + ']' + record.text);
        }
    });

    function proposed() {
        let pkId = $('#pkId').val();
        let telId = $('#getDealPk').val();
        var url = send + "/proposed/" + pkId+"?wfId="+pkId+"&telId="+telId;
        var width = '70%';
        // $.modal.open('拟办部门', url, width);
        var layerIdx = parent.layer.getFrameIndex(window.name);
        var iframeName = layerIdx ? 'layui-layer-iframe'+layerIdx : window.name;
        var config = {
            id: 'deptdialog',
            title: '拟办部门',
            width: width,
            url: url,
            callBack: function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler(iframeName);
            }
        };
        $.modal.openOptions(config);
    }

    function refreshTable() {
        $.table.refresh();
    }

    $('#dfmClaNo').change(function () {
        var dfmClaName = $("#dfmClaNo option:selected").text();
        var txtDCntAName = $("#txtDCntAName").val();
        var fromName = $("#fromName").val();
        $("#wsTopic").val(fromName + '[' + dfmClaName + ']' + txtDCntAName);
    })

    var sensitiveInfo = new Object();

        function setSensitiveId(id) {
        // sensitiveInfo.cardId = data[0].value;
        // sensitiveInfo.militaryId = data[1].value;
        // sensitiveInfo.realName = data[2].value;
        // sensitiveInfo.medicalCardNum = data[3].value;
        // sensitiveInfo.other = data[4].value;
        $('#sensitiveId').val(id);
    }
    function autoSendDept(e,acpId) {
        document.getElementById(acpId).value = e.text;
        let data = $('#form-user-add').serializeArray();
        var url = send + "/Intelligent";
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            success: function(result) {
                $.modal.msgSuccess(result.msg);
                $.table.refresh();
            }
        });
        // $.operate.submit(url, 'post', 'json', data);
    }
</script>
</body>
</html>

